from django.conf.urls import url
from rest_framework.routers import DefaultRouter, SimpleRouter

from . import views

urlpatterns = [
    # url(r'^books/$', views.BookDrfView.as_view({'get': 'list','post':'create'})),
    # url(r'^books/(?P<pk>\d+)/$', views.BookDrfView.as_view({'get': 'retrieve', 'put':'update','delete':'destroy'})),
    # url(r'^books/latest/$', views.BookDrfView.as_view({'get': 'latest'})),
    # url(r'^books/(?P<pk>\d+)/read/$', views.BookDrfView.as_view({'put': 'read'})),

    url(r'^heros/$', views.HerosView.as_view({'get': 'list'})),
    url(r'^heros/(?P<pk>\d+)/$', views.HerosView.as_view({'get': 'retrieve'})),
]

# # 1.实例化  路由器
# router = DefaultRouter()
router = SimpleRouter()
#
# # 2.注册路由
router.register('books', views.BookDrfView, basename="zhangsan")

print(router.urls)

# # 3.插入到路由列表
urlpatterns += router.urls

